<?php $__env->startSection('title','个人档案'); ?>
<?php $__env->startSection('css'); ?>
<link href="<?php echo e(asset(getThemeAssets('css/toastr.min.css'))); ?>" rel="stylesheet">
<style type="text/css">
    .widget .row span{
      font-size: 15px;
      font-weight: bold;
    }
    .p-md{
        padding-top: 6px;
        padding-bottom: 0px;
        margin-top: 0px;
        margin-bottom: 30px;
    }
    .m-b-md{
        padding-top: 3px;
    }
    .page-heading{
        padding-bottom: 2px;
    }
    .alert{
        /*padding-bottom: 0px;*/
        padding-left: 23px;
        padding-right: 23px;
        margin-bottom: 0px;
    }
    .alert p{
        font-size: 14px;
        font-weight: 12px;
    }
    .alert a{
        text-decoration: underline;
    }
    .canceled{
        margin: 0;
        padding: 0;
    }
    #login-form {
        margin-top: 30px;
    }
    #login-form img{
        width: 100%;
        margin-left: 0;
    }
    #footerrow {
      margin-top: 100px;
    }
    .col-sm-6 {
      padding: 3px;
    }
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>

<div class="row wrapper border-bottom page-heading">
  <div class="col-sm-10">
    <h2><?php echo trans('updatepassword.title'); ?></h2>
    <ol class="breadcrumb">
        <li>
            <a href="<?php echo e(url('admin')); ?>"><?php echo trans('home.title'); ?></a>
        </li>
        <li class="active">
            <strong><?php echo trans('updatepassword.title'); ?></strong>
        </li>
    </ol>
  </div>
</div>
<div id="login-form">
    <div class="logo">
        <img id="logo" src="<?php echo e(asset(getThemeAssets('img/logo2.png'))); ?>">
    </div>
    <div class="row">
    <div class="col-sm-8 col-sm-offset-2 col-lg-8 col-lg-offset-2">
          <form class="form-horizontal" method="post" action="<?php echo e(url('/login')); ?>">
            <div class="form-group">
                <label for="id" class="col-sm-3 control-label">教师编号</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" name="id"
                       autocomplete="off" value="<?php echo e($result['id']); ?>" placeholder="<?php echo e($result['id']); ?>" disabled="true" required>
                </div>
            </div>
            <div class="form-group">
                <label for="id" class="col-sm-3 control-label">教师姓名</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" name="name"
                       autocomplete="off" value="<?php echo e($result['name']); ?>" placeholder="请输入6个字符内的中文" required>
                </div>
            </div>
            <div class="form-group">
                <label for="id" class="col-sm-3 control-label">登录用户名</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" name="username"
                       autocomplete="off" value="<?php echo e($result['username']); ?>" placeholder="请输入至少6位以上的字母、数字、下划线" required>
                </div>
            </div>
            <div class="form-group">
                <label for="id" class="col-sm-3 control-label">新密码</label>
                <div class="col-sm-9">
                    <input type="password" class="form-control" name="password"
                       autocomplete="off" value="<?php echo e(old('password')); ?>" placeholder="请输入至少6位字母、数字、下划线" required>
                </div>
            </div>
            <div class="form-group">
                <label for="id" class="col-sm-3 control-label">确认密码</label>
                <div class="col-sm-9">
                    <input type="password" class="form-control" name="repassword"
                       autocomplete="off" value="<?php echo e(old('repassword')); ?>" placeholder="请再次输入密码" required>
                </div>
            </div>
            <div class="form-group" id="btn-group">
              <div class="col-sm-12 col-sm-offset-1">
                <?php echo e(csrf_field()); ?>

                <div class="col-sm-12">
                  <button id="btn1" type="button" class="btn btn-primary btn-block">确认修改</button>
                </div>
              </div>
            </div>
          </form>
        </div>
    </div>
</div>
                        

<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
<script src="<?php echo e(asset(getThemeAssets('js/toastr.min.js'))); ?>"></script>
<script type="text/javascript">
    $(function () {
        // js对表单内容要求进行验证
        $("input[name='name']").blur(function() {
            var name = $("input[name='name']").val();
            if (name == '') {
                swal("教师姓名不能为空！", "","warning");
                $("input[name='name']").focus();
            }else {
                var name_pattern = /^[\u4e00-\u9fa5]{0,6}$/;
                if (!name_pattern.exec(name)) {
                    swal("教师姓名为6个字符以内的中文！", "","warning");
                    $("input[name='name']").focus();
                }
            }
        });
        $("input[name='username']").blur(function() {
            var username = $("input[name='username']").val();
            if (username == '') {
                swal("登录用户名不能为空！", "","warning");
                $("input[name='username']").focus();
            }else {
                var username_pattern = /^(\w){6,20}$/;
                if (!username_pattern.exec(username)) {
                    swal("登录用户名至少6位以上的字母、数字、下划线！", "","warning");
                    $("input[name='username']").focus();
                }
            }
        });
        $("input[name='password']").blur(function() {
            var password = $("input[name='password']").val();
            if (password == '') {
                swal("密码不能为空！", "","warning");
                $("input[name='password']").focus();
            }else {
                var password_pattern = /^(\w){6,20}$/;
                if (!password_pattern.exec(password)) {
                    swal("密码至少6位以上的字母、数字、下划线！", "","warning");
                    $("input[name='password']").focus();
                }
            }
        });
        $("input[name='repassword']").blur(function() {
            var repassword = $("input[name='repassword']").val();
            if (repassword == '') {
                swal("请再次输入密码！", "","warning");
                $("input[name='repassword']").focus();
            }else {
                var password = $("input[name='password']").val();
                if (password != repassword) {
                    swal("两次输入的密码不一致！", "","warning");
                    $("input[name='repassword']").val('');
                    $("input[name='repassword']").focus();
                }
            }
        });
        $("#btn1").click(function() {
            var teachInfo = [];
            teachInfo['id'] = $("input[name='id']").val();
            teachInfo['name'] = $("input[name='name']").val();
            teachInfo['username'] = $("input[name='username']").val();
            teachInfo['password'] = $("input[name='password']").val();
            teachInfo['repassword'] = $("input[name='repassword']").val();
            if (teachInfo['password'] == '') {
                    swal("密码不能为空！", "","warning");
                    return;
            }
            // 添加header验证
            $.ajaxSetup ({
                     headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
            });
            $.ajax({
                url: "<?php echo e(url('/admin/updatepassword/editinfo')); ?>",
                type: "POST",
                dataType: "json",
                data: {name: teachInfo['name'], username: teachInfo['username'], password: teachInfo['password']},
                success: function(res) {
                            if (res['res'] == 1) {
                               swal("修改成功！","","success");
                            }else {
                                swal("修改失败，请联系管理员！", "","warning");
                            }
                }
            });
        });
        

    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.'.getTheme(), array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>